<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>临时事项-详细</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=f5a12a1d">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style type="text/css">
        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .user:hover {
            background-color: #cfd4d1;
        }

        .userbox .select.user {
            color: #fff;
            background-color: #045B9E;
        }

        .span-btn {
            position: absolute;
            left: 10px;
            margin-top: 4px;
            cursor: pointer;
        }

        .lineOne {
            text-align: left;
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        /*.auditorName {*/
            /*text-align: center;*/
        /*}*/

        .IcoNormal {
            float: left;
            border-bottom: 0px;
            border-left: 0px;
            background-color: transparent;
            width: 16px;
            height: 16px;
            vertical-align: middle;
            border-top: 0px;
            border-right: 0px;
            background-image: url(/dist/img/upload_normal.gif);
            background-repeat: no-repeat;
            float: left;
        }

        .progressobj {
            height: 20px;
        }

        .progressobj .delfile {
            float: left;
            margin-left: 10px;
        }

        .select {
            color: #fff;
            background-color: #045B9E;
        }

        td .sp-value {
            display: inline-block;
            padding-left: 6px;
            word-wrap: break-word;
        }

        td {
            color: #2a8cec;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: black;
            font-weight: normal !important;
        }

        .table-detail-payee:nth-child(even) td.td-title {
            background-color: white;
        }

        .printDiv {
            display: none;
        }

        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            display: block;
            padding: 0 4px;
            height: 22px;
            line-height: 22px;
            padding-left: 15px;
            margin: 0 auto;
            width: 70px;
            margin-top: 6px;
            border-radius: 4px;
        }

        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }

        #divUploadedFiles {
            /*padding: 4px;*/
            padding-bottom: 0;
        }
        .model-picker-dropdown {
            position: absolute;
            width: 315px;
            left: -9999px;
            top: -9999px;
            outline: 0;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            z-index: 999999;
            display: none;
            min-width: 200px;
            margin-bottom: 20px;
            margin-top: 5px;
        }
        .model-select-wrap {
            box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
        }
        .model-select-tab {
            border-bottom: 1px solid #ccc;
            background: #f5f5f5;
            font-size: 13px;
        }

        .model-select-tab > a {
            display: inline-block;
            padding: 4px 20px;
            border-left: 1px solid #ccc;
            border-bottom: 1px solid transparent;
            color: #4D4D4D;
            text-align: center;
            outline: 0;
            text-decoration: none;
            cursor: pointer;
            font-size: 14px;
            margin-bottom: -1px;
        }

        .model-select-tab > a.active {
            background: #fff;
            border-bottom: 1px solid #fff;
            color: #46A4FF;
        }

        .model-select-tab > a:first-child {
            border-left: none;
        }

        .model-select-tab > a:last-child.active {
            border-right: 1px solid #ccc;
        }

        .model-select-content {
            width: 100%;
            min-height: 50px;
            background-color: #fff;
            padding: 5px 5px;
        }

        .model-select {
            font-size: 16px;
        }

        .model-select dl {
            line-height: 2;
            clear: both;
            padding: 3px 0;
            margin: 0;
            max-height: 200px;
            overflow-y: scroll;
        }

        .model-select dt {
            position: absolute;
            width: 2.5em;
            font-weight: 500;
            text-align: right;
            line-height: 2;
        }

        .model-select dd {
            margin-left: 0;
            line-height: 2;
        }

        .model-select.province dd {
            margin-left: 3em;
        }

        .model-select a {
            display: inline-block;
            padding: 0 10px;
            outline: 0;
            text-decoration: none;
            white-space: nowrap;
            margin-right: 2px;
            text-decoration: none;
            color: #333;
            cursor: pointer;
        }

        .model-select a:hover,
        .model-select a:focus {
            background-color: #f1f8ff;
            border-radius: 2px;
            color: #46A4FF;
        }

        .model-select a.active {
            background-color: #46A4FF;
            color: #fff;
            border-radius: 2px;
        }
        .biTian {
            position: absolute;
            color: #000;
            margin-left: -15px;
            margin-top: 2px;
        }
         #tdQuYJL .wyui-autocomplete-panel{
            right:0px !important;
            left:auto !important;
        }
        #tdQuYZC  .wyui-autocomplete-panel{
            right:0px !important;
            left:auto !important;
        }
    </style>
</head>
<body>
<div class="oaLoad">
    <div class="loadGif" id="areaProgress"></div>
</div>
<iframe id="ifAttach" style="display:none"></iframe>
<div class="layout" style="left:0px;top:0px;right:0px;bottom:0px;" id="app">
    <div class="model-picker-dropdown" >
        <div class="model-select-wrap" >
            <div class="model-select-tab" >
                <a class="active" data-count="type">省</a><a class="" data-count="brand">市</a><a data-count="model"
                                                                                                class="">县</a>
            </div>
            <div class="model-select-content" >
                <div class="model-select type" data-count="type" style="display: block;">
                    <dl class="clearfix">
                        <a class="" :attr-id="item.id" v-for="item in itemsType">{{item.name}}</a>
                    </dl>
                </div>
                <div class="model-select brand" data-count="province">
                    <dl class="clearfix">
                        <a class="" :attr-id="item.id" v-for="(item,i) in itemsBran">{{item.name}}</a>
                    </dl>
                </div>
                <div class="model-select model" data-count="model">
                    <dl class="clearfix">
                        <a class="" :attr-id="item.id" v-for="(item,i) in itemsMod">{{item.name}}</a>
                    </dl>
                </div>
            </div>
        </div>
    </div>
    <div class="center" style="padding-left:8px;padding-right:8px;">
        <div class="div-td-content-more"><i></i></div>
        <table class="table-detail">
            <tr class="no-print">
                <td colspan="6" class=" no-print td-module" style="background: yellow;">基本信息</td>
            </tr>
            <tr>
                <td style="width:16%;" class="td-title">申请人</td>
                <td style="width:17%;">{{tmpEvent.main.createUserName}}
                <td style="width:16%;" class="td-title">申请时间</td>
                <td style="width:17%;">{{tmpEvent.main.createTime}}
                </td>
                <td style="width:16%;" class="td-title">部门</td>
                <td>
                    {{tmpEvent.main.orgName}}
                </td>
            </tr>
            <tr>
                <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>事项类型</td>
                <td style="width:17%;">
                    <select v-if="pageType=='edit'" v-model="tmpEvent.main.type" @change="getType">
                        <option v-for="option in typeList" :value="option.name">{{option.name}}
                        </option>
                    </select>
                    <span v-else style="color:red;">{{tmpEvent.main.type}}</span>
                </td>
                <td colspan="4"></td>
            </tr>

                <!--<tr>-->
                    <!--<td class="td-title">主题</td>-->
                    <!--<td colspan="5" style="text-align:left;margin-left: 16px">-->
                        <!--<input type="text" v-model="tmpEvent.main.title"/>-->
                    <!--</td>-->
                <!--</tr>-->

            <!--新机注册字段-->
            <template v-if="tmpEvent.main.type == '新机注册'">
                <tr>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>客户姓名</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.customerName"/>
                        <span v-else>{{tmpEvent.main.customerName}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>联系电话</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.customerTel"/>
                        <span v-else>{{tmpEvent.main.customerTel}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>地址(省/市)</td>
                    <td>
                        <input type="text" class="selectModel" v-if="pageType=='edit'" :value="showDz()">
                        <span v-else v-html="showDz()"></span>
                    </td>
                </tr>
                <tr>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>机型</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.modelName"/>
                        <span v-else>{{tmpEvent.main.modelName}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>序列号</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.sequence"/>
                        <span v-else>{{tmpEvent.main.sequence}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>交机状态</td>
                    <td>
                        <select id="deliveryState" v-if="pageType=='edit'" v-model="tmpEvent.main.deliveryState"
                                style=" background-color: white;width:100%;color: rgb(22, 155, 213);border-style:none;">
                            <option value=0>未交机</option>
                            <option value=1>已交机</option>
                        </select>
                        <span v-else>{{Flag2BuyType(tmpEvent.main.deliveryState)}}</span>
                    </td>
                </tr>
                <tr>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="tmpEvent.main.deliveryState=='1' && pageType=='edit'">*</i>交机日期</td>
                    <td style="width:17%;">
                    <input v-if="pageType=='edit'" type="text" v-model="tmpEvent.main.deliveryDate" @focus="showDatePicker($event,'deliveryDate')" placeholder="请选择时间"/>
                        <span v-else>{{tmpEvent.main.deliveryDate}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="tmpEvent.main.deliveryState=='1' && pageType=='edit'">*</i>购买方式</td>
                    <td style="width:17%;">
                        <select id="buyType" v-if="pageType=='edit'" v-model="tmpEvent.main.buyType"
                                style=" background-color: white;width:100%;color: rgb(22, 155, 213);border-style:none;">
                            <option selected="selected">全款</option>
                            <option>内部分期</option>
                            <option>融资租赁</option>
                            <option>融资租赁打包</option>
                        </select>
                        <span v-else>{{tmpEvent.main.buyType}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"></td>
                    <td></td>
                </tr>
            </template>

            <!--商务条件字段-->
            <template v-if="tmpEvent.main.type == '商务条件申请'">
                <tr>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>客户姓名</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.customerName"/>
                        <span v-else>{{tmpEvent.main.customerName}}</span>
                    </td>
                    <td style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>机型</td>
                    <td style="width:17%;">
                        <input type="text" v-if="pageType=='edit'" v-model="tmpEvent.main.modelName"/>
                        <span v-else>{{tmpEvent.main.modelName}}</span>
                    </td>
                    <td  style="width:16%;" class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>区域经理</td>
                    <td id="tdQuYJL">
                        <input type="text" v-if="pageType=='edit'" class="regionManagerName" v-model="tmpEvent.main.regionManagerName"/>
                        <span v-else>{{tmpEvent.main.regionManagerName}}</span>
                    </td>
                </tr>
                <tr>
                    <td  style="width:16%;" class="td-title">大区经理</td>
                    <td id="tdDaQJL">
                        <input type="text" v-if="pageType=='edit'" class="bigRegionManagerName" v-model="tmpEvent.main.bigRegionManagerName"/>
                        <span v-else>{{tmpEvent.main.bigRegionManagerName}}</span>
                    </td>
                    <td  style="width:16%;" class="td-title">区域总监</td>
                    <td id="tdQuYZJ">
                        <input type="text" v-if="pageType=='edit'" class="regionDirectorName" v-model="tmpEvent.main.regionDirectorName"/>
                        <span v-else>{{tmpEvent.main.regionDirectorName}}</span>
                    </td>
                    <td  style="width:16%;" class="td-title">区域支持</td>
                    <td id="tdQuYZC">
                        <input type="text" v-if="pageType=='edit'" class="regionSupportName" v-model="tmpEvent.main.regionSupportName"/>
                        <span v-else>{{tmpEvent.main.regionSupportName}}</span>
                    </td>
                </tr>
                <tr>
                    <td  style="width:16%;" class="td-title">厂家支持</td>
                    <td id="tdChJZC">
                        <input type="text" v-if="pageType=='edit'" class="manufactorSupportName" v-model="tmpEvent.main.manufactorSupportName"/>
                        <span v-else>{{tmpEvent.main.manufactorSupportName}}</span>
                    </td>
                    <td class="td-title"></td>
                    <td class="td-value"></td>
                    <td class="td-title"></td>
                    <td class="td-value"></td>
                </tr>
            </template>

            <tr>
                <td class="td-title"><i class="biTian" v-if="pageType=='edit'">*</i>详细描述</td>
                <td colspan="5"
                    style="text-align:left;line-height:20px;min-height:56px !important;height:56px;">
                    <textarea v-if="pageType=='edit'" type="text"
                              v-model="tmpEvent.main.description"></textarea>
                    <span v-else class="sp-value">{{tmpEvent.main.description}}</span>
                </td>
            </tr>

            <tr>
                <td class="td-title">附件</td>
                <td :colspan="pageType=='edit'?2:5">
                    <div id="divUploadedFiles">
                        <div v-for="(attach,i) in tmpEvent.attaches" class="fj-tanzhongStyle ">
                            <b :class="fjStyle(attach.name)"></b>
                            <div class="name" v-if="attach.name" :title="attach.name"
                                 v-on:click="download(attach.url,attach.name)">{{attach.name}}
                            </div>
                            <div class="down"><a href="javascript:void(0)" class="nui-txt-link"
                                                 v-on:click="download(attach.url,attach.name)">下载</a></div>
                            <div class="del" v-if="pageType=='edit'"><a href="javascript:void(0)" class="nui-txt-link"
                                                                        v-on:click="deleteFile(i)">删除</a></div>
                            <!--<div class="info"><span class="nui-txt-suc">上传完成</span></div>-->
                        </div>
                    </div>
                    <div v-if="tmpEvent.attaches.length==0" style="text-align: left;"><span class="sp-value">无</span></div>
                </td>
                <td v-if="pageType=='edit'" colspan="3">
                    <div id="divUpload">
                        添加附件
                    </div>
                </td>
            </tr>
        </table>
        <!--<table class="table-detail no-print" style="border-top-width:0px;">-->
        <!--<tr>-->
        <!--<td class="td-title" style="width:16%;">附件</td>-->
        <!--<td style="width:33%;" :colspan="pageType=='edit'?1:2">-->
        <!--<div id="divUploadedFiles">-->
        <!--<div v-for="(attach,i) in tmpEvent.attaches" class="progressobj">-->
        <!--<input type="button" class="IcoNormal" style="float:left;"/>-->
        <!--<div class="filename" style="float:left;">-->
        <!--{{attach.name}}-->
        <!--</div>-->
        <!--<div class="delfile">-->
        <!--<span v-if="pageType=='edit'"><a href="javascript:void(0);"-->
        <!--v-on:click="deleteFile(i)">删除</a></span>-->
        <!--<a href="javascript:void(0);"-->
        <!--v-on:click="download(attach.url,attach.name)">下载</a>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</td>-->
        <!--<td v-if="pageType=='edit'">-->
        <!--<div id="divUpload">-->
        <!--添加附件-->
        <!--</div>-->
        <!--</td>-->
        <!--</tr>-->
        <!--</table>-->
        <table class="table-detail no-print" style="border-top-width:0px;">
            <tr>
                <td class=" td-module" colspan="5" style="background: yellow;">审批进度</td>
            </tr>
        </table>
        <table class="table-detail no-print" style="border-top-width:0px;">
            <tr>
                <td class="td-title" style="width:16.5%;">审核顺序</td>
                <td class="td-title" style="width:17%;">审核人员</td>
                <td class="td-title" style="width:16%;">审核状态</td>
                <td class="td-title" style="width:17%;">审核时间</td>
                <td class="td-title">审核意见</td>
            </tr>
            <tr v-for="(item,i) in tmpEvent.auditors">
                <td>
                    <span style="font-size:20px;margin-top: -1px;left: 20px;" v-if="pageType=='edit'" class="span-btn"
                          @click="addItem('auditors','Audit')"> + </span>

                    <span>第{{i+1}}审核人</span>

                    <span style="font-size:20px;left: 115px;top:-5px;" v-if="pageType=='edit'" class="span-btn"
                          @click="delItem('auditors',i,'审核人')"> - </span>

                </td>
                <td style="text-align: left;">
                    <input v-if="pageType=='edit'" class="auditorName" type="text"
                           :value="item.auditorRoleName" :idx="i"/>
                    <span style="padding-left: 6px;" v-else>{{item.auditorName}}-{{item.roleName}}</span>
                </td>
                <td>
                    <span v-if="item.auditFlag==0" style="color:red;">{{convertAuditFlagToName(item.auditFlag)}}</span>
                    <span v-else>{{convertAuditFlagToName(item.auditFlag)}}</span>
                </td>
                <td>{{item.auditTime}}</td>
                <!--<td ><input type="text" v-model="item.auditAdvise"/></td>-->
                <td class="lineOne"><span style="padding-left: 4px;">{{item.auditAdvise}}</span></td>
            </tr>
        </table>
        <!--抄送人 和  付款人-->
        <table class="table-detail" style="border-top-width:0px;margin-bottom: 2px;">
            <tr class="printDiv">
                <td class="td-title " style="width:16.5%;">审核人</td>
                <td class="" colspan="5">
                    <div v-for="(item,i) in tmpEvent.auditors" class="user">{{item.auditorName}};
                    </div>
                </td>
            </tr>
            <tr>
                <td class="td-title" style="width:16.5%;">抄送人</td>
                <td colspan="5">
                    <div id="user" style="padding-left:6px;"
                         v-on:click.stop="inputFocus('txtCopier')">
                        <div v-for="(user,i) in tmpEvent.copiers" class="user"
                             v-bind:class="{ select: copierSelectedIdx == i }"
                             v-on:click="selectUser(i,'copierSelectedIdx')">{{user.copyPersonName}};
                        </div>
                        <input v-if="pageType=='edit'" class="pull-left copier" id="txtCopier"
                               style="width:100px"
                               type="text" @keyup.delete="deleteUser"/>
                    </div>
                </td>
            </tr>
            <tr v-if="tmpEvent.main.copierReturnReason">
                <td class="td-title" style="width:16%;">抄送人驳回原因</td>
                <td colspan="5" style="text-align:left;">
                    <span class="sp-value">{{tmpEvent.main.copierReturnReason}}</span>
                </td>
            </tr>
        </table>
        <!--历史驳回记录-->
        <table class="table-detail" style="width: 100%;"
               v-if="tmpEvent.historys && tmpEvent.historys.length>0">
            <tr>
                <td class="td-title" colspan="6"
                    style="text-align: center;background-color: #d3e8fd;">历史驳回记录
                </td>
            </tr>
            <template v-for="(item,i) in tmpEvent.historys">
                <tr>
                    <td class="td-title">驳回人员</td>
                    <td><span class="pull-left" style="padding-left: 4px;">{{item.auditorName}}</span></td>
                    <td class="td-title">驳回时间</td>
                    <td><span class="pull-left" style="padding-left: 4px;">{{item.auditTime}}</span></td>
                    <td class="td-title">驳回原因</td>
                    <td class="lineOne"><span style="padding-left: 4px;">{{item.auditAdvise}}</span></td>
                </tr>
            </template>
        </table>
    </div>
    <div class="south no-print" style="height:50px;line-height:50px;text-align:center;">
        <input type="button" style="margin-left:20px;" v-if="pageType=='edit'"
               value="保存草稿" class="btn oaBtn btn-sm" @click="save(-1)"/>
        <input type="button" style="margin-left:20px;" v-if="pageType=='edit'"
               value="提交申请" class="btn oaBtn btn-sm" @click="save(0)">
        <input type="button" style="margin-left:20px;"
               v-if="pageType=='applyAudit' && tmpEvent.main.auditFlag=='0' && tmpEvent.main.currentAuditorId==currentUser.id"
               value="通过" class="btn oaBtn btn-sm" @click="applyAudit('1')">
        <input type="button" style="margin-left:20px;"
               v-if="pageType=='applyAudit' && tmpEvent.main.auditFlag=='0' && tmpEvent.main.currentAuditorId==currentUser.id"
               value="驳回" class="btn oaBtn btn-sm" @click="applyAudit('2')">
        <input type="button" style="margin-left:20px;" v-if="showCopierReturn()" value="驳回"
               class="btn oaBtn btn-sm" @click="copierReturn('0')">
        <input type="button" style="margin-left:20px;" value="返回上一页" class="btn oaBtn btn-sm"
               @click="goBack">
        <input class="btn oaBtn btn-sm" style="margin-left:20px;" type="button" value="打印" @click="print"
               v-if="tmpEvent.main.auditFlag=='1'">
    </div>
</div>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=63aed32f"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/dist/js/pages/apply/tmpevent/class.js"></script>
<script type="text/javascript" src="/dist/js/pages/system/systemService.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/commonService.js"></script>
<script type="text/javascript" src="/dist/plugins/print/print.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo,.lineF", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
    $(function () {
        $("body").on("click", ".selectModel", function (e) {
            if ($(".model-picker-dropdown").is(":hidden")) {
                $(".model-picker-dropdown").css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left-53,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            } else {
                $(".model-picker-dropdown").hide();
            }
        });
        $("body").on("click", ".model-select-tab a", function (e) {
            $(this).parent().find("a").removeClass("active");
            $(this).addClass("active");
            var boxName = $(this).attr("data-count");
            $(".model-select").hide();
            $(".model-select-content" + " ." + boxName).show();
        });
        $("body").on("click", ".model-select  a", function (e) {
            if ($(this).hasClass("active")) {
                return false;
            }
            $(this).parent().find("a").removeClass("active");
            var id = $(this).attr("attr-id");
            $(this).addClass("active");
            var val = $(this).text();
            if ($(this).parents(".model-select").hasClass("type")) {
                $(".model-select-tab a").removeClass("active");
                $(".model-select-tab a[data-count=brand]").addClass("active");
                $(".model-select").hide();
                app.tmpEvent.main.provinceName = val;
                app.tmpEvent.main.cityName = '';
                app.tmpEvent.main.countyName = '';
                app.getCity(id);
                $(".model-select-content .brand").show();

            } else if ($(this).parents(".model-select").hasClass("brand")) {
                $(".model-select-tab a").removeClass("active");
                var id = $(this).attr("attr-id");
                $(".model-select-tab a[data-count=model]").addClass("active");
                $(".model-select").hide();
                app.tmpEvent.main.cityName = val;
                app.tmpEvent.main.countyName = '';
                app.getCounty(id);
                $(".model-select-content .model").show();

            } else {
                app.tmpEvent.main.countyName = val;
                $(".model-picker-dropdown").hide();
            }
        })
        $("body").on("click", ".model-picker-dropdown", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".model-picker-dropdown").hide();
        });
    });
</script>
<script type="text/javascript">
    var api = frameElement.api, W = api.opener;

    var app = new Vue({
        el: "#app",
        data: {
            isGo:true,//是否可执行ajax
            provinceId: '省份',
            cityId: '市区',
            countyId: '县',
            itemsCom: [],
            itemsBran: [],
            itemsType: [],
            itemsMod: [],
            xinji:false,
            currentUser: getCurrentUser(),
            pageType: $.wyui.page.urlParams.pageType,
            typeList: [
//                {name: '商务条件申请'}
            ],
            tmpEvent: {
                main: new TmpEvent.Main(),
                auditors: [
                    new TmpEvent.Audit(),
                    new TmpEvent.Audit(),
                    new TmpEvent.Audit()
                ],
                copiers: [],
                attaches: []//附件
            },
            auditorList:[],
            SWTJ:{
                auditors:[],
                copiers:[]
            },
            userInfo:[],
            uploader: null,
            copierSelectedIdx: -1,
            price: 0,
            priceChinese: ""
        },
        methods: {
            showCopierReturn: function () {
                if (this.tmpEvent.main.auditFlag != '-1' && this.tmpEvent.main.auditFlag != '2') {
                    var copierIds = new Array();
                    for (var i = 0; i < this.tmpEvent.copiers.length; i++) {
                        copierIds.push(this.tmpEvent.copiers[i].copyPersonId);
                    }
                    return $.inArray(currentUser.id, copierIds) > -1;
                }
                return false;
            },
            copierReturn: function (type) {
                $.dialog({
                    content: 'url:copierReturnReason.html?id=' + this.tmpEvent.main.id + "&type=" + type + "&t=" + new Date(),
                    title: '填写驳回原因',
                    width: 300,
                    height: 200,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            print: function () {
                $("#app").print({
                    globalStyles: false,
                    mediaPrint: false,
                    stylesheet: "/dist/css/page/print.css?t=" + new Date(),
                    noPrintSelector: ".no-print",
                    iframe: true,
                    append: null,
                    prepend: null,
                    manuallyCopyFormValues: true,
                    deferred: $.Deferred()
                });
            },
            convertAuditFlagToName: function (auditFlag) {
                //auditFlag:-1,0,1,2,3,4,5,6
                switch (auditFlag) {
                    case -1:
                        return "未提交";
                        break;
                    case 0:
                        return "审核中";
                        break;
                    case 1:
                        return "通过";
                        break;
                    case 2:
                        return "驳回";
                        break;
                    default :
                        break;
                }
            },
            addItem: function (prop, className) {
                this.tmpEvent[prop].push(new TmpEvent[className]());
                setTimeout(function () {
                    initAutoComplete();
                }, 300);

            },
            delItem: function (prop, i, desc) {
                if (this.tmpEvent[prop].length <= 1) {
                    alert("请至少保留一位审核人！")
                    return
                }
                this.tmpEvent[prop].splice(i, 1);
            },
            save: function (auditFlag) {
                var that = this;
                if (!that.tmpEvent.main.type) {
                    alert("请选择事项类型");
                    return;
                }
                if (auditFlag == "0") {
                    if (that.tmpEvent.main.type == '新机注册'){
                        if (!that.tmpEvent.main.customerName) {
                            alert("请填写客户姓名");
                            return;
                        }
                        if (!that.tmpEvent.main.customerTel) {
                            alert("请填写客户电话");
                            return;
                        }
                        if (!that.tmpEvent.main.provinceName) {
                            alert("请填写客户地址");
                            return;
                        }
                        if (!that.tmpEvent.main.modelName) {
                            alert("请填写机型");
                            return;
                        }
                        if (!that.tmpEvent.main.sequence) {
                            alert("请填写序列号");
                            return;
                        }
                        if (!that.tmpEvent.main.deliveryState) {
                            alert("请选择交机状态");
                            return;
                        }
                        if (that.tmpEvent.main.deliveryState == '1') {
                            if (!that.tmpEvent.main.deliveryDate) {
                                alert("请选择交机日期");
                                return;
                            }
                            if (!that.tmpEvent.main.buyType) {
                                alert("请选择购买方式");
                                return;
                            }
                        }
                    }else if (that.tmpEvent.main.type == '商务条件申请') {
                        if (!that.tmpEvent.main.customerName) {
                            alert("请填写客户姓名")
                            return;
                        }
                        if (!that.tmpEvent.main.modelName) {
                            alert("请填写机型")
                            return;
                        }
                        if (!that.tmpEvent.main.regionManagerName) {
                            alert("请填写区域经理姓名")
                            return;
                        }
                    }
                    if (!that.tmpEvent.main.description) {
                        alert("请填写详细描述");
                        return;
                    }
                }
                that.tmpEvent.main.auditFlag = auditFlag;
                that.tmpEvent.main.description = that.tmpEvent.main.description.replace(/\s+/g,"");
                if (parseInt($.wyui.page.urlParams.isAdd) == 1) {
                    that.tmpEvent.main.id = '';
                }
                if(that.isGo){
                    that.isGo = false;
                    $.wyui.postLoadMethod(urlConfig.apply.tmpevent.save, trimRN(that.tmpEvent), function (data) {
//                        alert("操作成功");
                        that.isGo=true;
//                    parent.refresh();
//                    top.refreshTabById("2018012916394CDBA7CCAE5D2225DCC0","no");
                        var $iframe = top.findIframeByName("临时事项");
                        $iframe[0].contentWindow.refresh();
                        setTimeout(function () {
                            api.close();
                        }, 1000);
                        that.showModel(200, "操作成功")
                    },false,true);
                }

            },
            //提示弹框
            showModel: function (width, title) {
                parent.$.alert({type:'topAlert',width:width,title:title})
            },
            applyAudit: function (auditFlag) {
                var that = this;
                if (auditFlag == '1') {
                    top.$.alert({
                        win: this,
                        height: 180,
                        width: 300,
                        icon: '3', //1成功 2失败 3提示 不传代表无图标
                        title: '确定要通过吗？',
                        blankclose: true,//点击空白是否可关闭
                        ok: "通过",//是否显示确认按钮,
                        okCallback: function (em, opts) {
                            //确认按钮回调
                            em.remove()
                            opts.close && opts.close()
                            if(that.isGo){
                                that.isGo = false;
                                var advise = "同意！";
                                $.wyui.postLoadMethod(urlConfig.apply.tmpevent.applyAudit, {
                                    id: that.tmpEvent.main.id,
                                    userId: getCurrentUser().id,
                                    auditFlag: auditFlag,
                                    advise: advise
                                }, function () {
//                        alert("审核成功");
                                    that.isGo = true;
                                    if (top.findTabPanelByName("临时事项")) {
                                        var $iframe = top.findIframeByName("临时事项");
                                        $iframe[0].contentWindow.refresh();
                                    }
//                        api.close();
                                    setTimeout(function () {
                                        api.close();
                                    }, 1000);
                                    that.showModel(200, "审核成功")
                                },false,true);
                            }
                        },
                        cancel: "取消",
                        cancelCallback: function (em, opts) {
                            em.remove()
                            opts.close && opts.close()
                        }
                    })
                } else if (auditFlag == '2') {
                    this.copierReturn(1)
                    return;
                }
            },
            goBack: function () {
                api.close();
            },
            showDatePicker: function (e,type) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        if(type=="deliveryDate"){
                            that.tmpEvent.main.deliveryDate = dp.cal.getNewDateStr();
                        }
                        return true;
                    },
                    oncleared:function (dp) {
                        that.tmpEvent.main.deliveryDate = '';
                        return true;
                    }
                });
                $(e.target).blur();
            },
            Flag2BuyType:function (flage) {
                if (flage == "0") return "未交机";
                if (flage == "1") return "已交机";
            },
            showDz: function () {
                var html = '';
                if (this.tmpEvent.main.provinceName) {
                    html += this.tmpEvent.main.provinceName;
                }
                if (this.tmpEvent.main.cityName != '') {
                    html += "-" + this.tmpEvent.main.cityName;
                }
                if (this.tmpEvent.main.countyName != '') {
                    html += "-" + this.tmpEvent.main.countyName;
                }
                return html;
            },
            getCity: function (id) {
                var that = this;
                that.cityId = "市区";
                that.countyId = "县";
                that.itemsMod = "";
                var data = {};
                $.wyui.postMethod('/intentCustomer/getForProvinceById.json', {'id': id}, function (r) {
                    console.log(r);
                    that.itemsBran = r.records;
                })
            },
            getCounty: function (id) {
                var that = this;
                $.wyui.postMethod('/intentCustomer/getForProvinceById.json', {'id': id}, function (r) {
                    console.log(r);
                    that.itemsMod = r.records;
                })

            },
            inputFocus: function (id) {
                $("#" + id).focus();
            },
            selectUser: function (i, prop) {
                this.copierSelectedIdx = -1;
                this[prop] = i;
            },
            unselectUser: function () {
                this.copierSelectedIdx = -1;
            },
            deleteUser: function (event) {
                if (event.keyCode == 46 || event.keyCode == 8 && event.target.value == "") {
                    if (this.copierSelectedIdx > -1) {
                        this.tmpEvent.copiers.splice(this.copierSelectedIdx, 1);
                        this.copierSelectedIdx = -1;
                    } else {
                        this.copierSelectedIdx = this.tmpEvent.copiers.length - 1;
                    }
                }
            },
            deleteFile: function (i) {
                if (window.confirm("确定要删除该附件吗?")) {
                    this.tmpEvent.attaches.splice(i, 1);
                }
            },
            download: function (attachId, fileName) {
                downloadFile(attachId,fileName)
                return false;
            },
            fjStyle: function (fjName) {
                if (fjName) {
                    var type = fjName.substring(fjName.lastIndexOf('.') + 1);
                    return 'img fj-' + type
                }
                return 'img'
            },
            getType:function () {
                var that = this;
                if(that.tmpEvent.main.type == '新机注册'){
                    that.xinji = true;
                    that.tmpEvent.auditors = [];
                    that.tmpEvent.copiers = [];
                    var newArr = [];
                    for(var i = 0;i < that.auditorList.length;i++){
                        newArr.push(that.auditorList[i]);
                    }
                    console.log(newArr)
                    that.tmpEvent.auditors = newArr;
                    that.tmpEvent.main.deliveryDate = '';
                    that.tmpEvent.main.deliveryState = '';
                    that.tmpEvent.main.buyType = '';
                    setTimeout(function () {
                        initAutoComplete();
                    }, 300);
                    console.log(that.tmpEvent.auditors)
                } else if(that.tmpEvent.main.type == '商务条件申请'){
                    that.tmpEvent.auditors = [];
                    var newArr = [];
                    var newArrList = [];
                    for(var i = 0;i < that.SWTJ.auditors.length;i++){
                        newArr.push(that.SWTJ.auditors[i]);
                    }
                    for(var j = 0;j < that.SWTJ.copiers.length;j++){
                        newArrList.push(that.SWTJ.copiers[j]);
                    }
                    console.log(newArr)
                    that.tmpEvent.auditors = newArr;
                    that.tmpEvent.copiers = newArrList;
                    that.tmpEvent.main.deliveryDate = '';
                    that.tmpEvent.main.deliveryState = '';
                    that.tmpEvent.main.buyType = '';
                    setTimeout(function () {
                        initAutoComplete();
                    }, 300);
                    console.log(that.tmpEvent.auditors)
                } else {
                    that.tmpEvent.auditors = [];
                    that.tmpEvent.copiers = [];
                    var list = new Array();
                    $.wyui.postMethod(urlConfig.system.user.getFirstParent, {userId: getCurrentUser().id}, function (data) {
                        console.log(data)
//                        list.push({auditorId : data.id,auditorName : data.roleName + "-" + data.name})
                        list.push({auditorId : data.id,auditorName : data.name + "-" + data.roleName,auditorRoleName:data.name + "-" + data.roleName})
                        list.push({auditorId : "",auditorName : "",auditorRoleName:""})
                        list.push({auditorId : "",auditorName : "",auditorRoleName:""})
                        console.log(list)
                        that.tmpEvent.auditors = list;
                        that.tmpEvent.main.deliveryDate = '';
                        that.tmpEvent.main.deliveryState = '';
                        that.tmpEvent.main.buyType = '';
                        setTimeout(function () {
                            initAutoComplete();
                        }, 300);
                    });
                }
            }

        },

        mounted: function () {
            //页面操作状态
            this.pageType = $.wyui.page.urlParams.pageType;
            //上传附件
            var that = this;
            this.uploader = WebUploader.create({
                // 选完文件后，是否自动上传。
                auto: true,
                // swf文件路径
                swf: "/statics/plugin/webuploader-0.1.5/Uploader.swf",
                // 文件接收服务端。
                server: server.fjIp + "/attach/uploadFile.json",
                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#divUpload',
                duplicate: true
            });
            this.uploader.on("uploadStart", function () {
                $("#progress").show();
            });
            this.uploader.on("uploadComplete", function () {
                $("#progress").hide();
            });
            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
            this.uploader.on('uploadSuccess', function (file, response) {
                if (response._raw == "文件上传出错！") {
                    alert("文件上传出错！");
                } else {
                    that.tmpEvent.attaches.push({
                        id: response.id,
                        name: response.name,
                        url: response.url
                    });
                }
            });
            // 文件上传失败，显示上传出错。
            this.uploader.on('uploadError', function (file) {
                alert("上传失败！");
            });

            //获取临时事项类型
            $.wyui.postMethod("/aplType/getNameList.json", {modelName:'tmpevent'}, function (r) {
                for (var i=0;i<r.names.length;i++) {
                    var o = {
                        "value": r.names[i].name,
                        "name": r.names[i].name
                    }
                    that.typeList.push(o)
                }
            });

            /*获取省份*/
            $.wyui.postMethod('/intentCustomer/getForProvinceById.json', {'id': '0'}, function (r) {
                that.itemsType = r.records;
            })

            //获取新机注册的默认审核人
            $.wyui.postMethod("/event/getAuditorsForXJZC.json",
                {companyId: getCurrentUser().companyId,userId:getCurrentUser().id}, function (data) {
                    console.log(data.sendData)
                    that.auditorList = data;
                    console.log(that.auditorList)
                });

            //获取商务条件申请默认审核人和抄送人
            $.wyui.postMethod("/event/getAuditorsAndCopiers.json",
                {companyId: getCurrentUser().companyId,userId:getCurrentUser().id}, function (data) {
                    console.log(data)
                    that.SWTJ = data;
                    console.log(that.SWTJ)
            });

            //编辑
            if (parseInt($.wyui.page.urlParams.id) > 0) {
                $.wyui.postMethod(urlConfig.apply.tmpevent.getById, {id: $.wyui.page.urlParams.id}, function (data) {
                    var params = {moduleId: data.main.id};
                    commonService.getAttachesByModuleId(params, function (attaches) {
                        if (attaches) {
                            data.attaches = attaches;
                        }
                        that.tmpEvent = data;
                        var auditorRole = "";
                        for(var i=0;i < data.auditors.length;i++){
                            auditorRole = data.auditors[i].auditorName + "-" +data.auditors[i].roleName;
                            data.auditors[i].auditorRoleName = auditorRole;
                            console.log(data.auditors[i])
                        }
                    });
                });
            } else {
                $.wyui.postMethod(urlConfig.system.user.getFirstParent, {userId: getCurrentUser().id}, function (data) {
                    console.log(data)
                    app.tmpEvent.auditors[0].auditorId = data.id;
//                    app.tmpEvent.auditors[0].auditorName = data.roleName + "-" + data.name;
                    var auditName =  data.name;
                    if(auditName.length == 2){
                        auditName = auditName.substring(0,1)+"   "+ auditName.substring(1,2)
                    }
                    app.tmpEvent.auditors[0].auditorName = auditName + "-" + data.roleName;
                    app.tmpEvent.auditors[0].auditorRoleName = auditName + "-" + data.roleName;
                });
            }
        }
    });
</script>
<script>
    $(function () {
        initAutoComplete();
    });

    function initAutoComplete() {
        $(".auditorName,.copier,.regionManagerName,.bigRegionManagerName,.regionDirectorName,.regionSupportName,.manufactorSupportName").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                if ($(this).hasClass("auditorName")) {
                    var idx = $(this).attr("idx");
                    app.tmpEvent.auditors[idx].auditorId = user.id;
                    var auditName =  user.name
                    if(auditName.length == 2){
                        auditName = auditName.substring(0,1)+"   "+ auditName.substring(1,2)
                    }
                    app.tmpEvent.auditors[idx].auditorName = auditName + "-" + user.roleName;
                    app.tmpEvent.auditors[idx].auditorRoleName = auditName + "-" + user.roleName;
                } else if($(this).hasClass("regionManagerName")){
                    app.tmpEvent.main.regionManagerId =  user.id;
                    app.tmpEvent.main.regionManagerName =  user.name;
                    $.wyui.postMethod("/event/getUserInfoByUserId.json", {userId: app.tmpEvent.main.regionManagerId}, function (data) {
                        console.log(data)
                        this.userInfo = data;
                        console.log(this.userInfo)
                        for(var i = 0;i < this.userInfo.length; i++){
                            if(this.userInfo[i].roleName == '大区经理'){
                                app.tmpEvent.main.bigRegionManagerId =  this.userInfo[i].userId;
                                app.tmpEvent.main.bigRegionManagerName =  this.userInfo[i].userName;
                            }
                            if(this.userInfo[i].roleName == '区域总监'){
                                app.tmpEvent.main.regionDirectorId =  this.userInfo[i].userId;
                                app.tmpEvent.main.regionDirectorName =  this.userInfo[i].userName;
                            }
                            if(this.userInfo[i].roleName == '区域支持'){
                                app.tmpEvent.main.regionSupportId =  this.userInfo[i].userId;
                                app.tmpEvent.main.regionSupportName =  this.userInfo[i].userName;
                            }
                            if(this.userInfo[i].roleName == '厂家支持'){
                                app.tmpEvent.main.manufactorSupportId =  this.userInfo[i].userId;
                                app.tmpEvent.main.manufactorSupportName =  this.userInfo[i].userName;
                            }
                        }
                    });
                }
                else if($(this).hasClass("bigRegionManagerName")){
                    app.tmpEvent.main.bigRegionManagerId =  user.id;
                    app.tmpEvent.main.bigRegionManagerName =  user.name;
                }
                else if($(this).hasClass("regionDirectorName")){
                    app.tmpEvent.main.regionDirectorId =  user.id;
                    app.tmpEvent.main.regionDirectorName =  user.name;
                }
                else if($(this).hasClass("regionSupportName")){
                    app.tmpEvent.main.regionSupportId =  user.id;
                    app.tmpEvent.main.regionSupportName =  user.name;
                }
                else if($(this).hasClass("manufactorSupportName")){
                    app.tmpEvent.main.manufactorSupportId =  user.id;
                    app.tmpEvent.main.manufactorSupportName =  user.name;
                }
                else if ($(this).hasClass("copier")) {
                    var userIds = new Array();
                    for (var i = 0; i < app.tmpEvent.auditors.length; i++) {
                        userIds.push(app.tmpEvent.auditors[i].auditorId);
                    }
                    for (var i = 0; i < app.tmpEvent.copiers.length; i++) {
                        userIds.push(app.tmpEvent.copiers[i].copyPersonId);
                    }
                    if ($.inArray(user.id, userIds) == -1) {
                        app.tmpEvent.copiers.push({copyPersonId: user.id, copyPersonName: user.name});
                    } else {
                        alert("审核人、抄送人不能重复输入");
                    }
                    $(this).val("");
                }
                return false;
            },
            height: 210,
            width: 300
        });
    }
</script>
</body>
</html>